<?php
/**
 * Created by Engineer CuiLiwu.
 * Project: deal.
 * Date: 2018/5/18-9:41
 * License Hangzhou orce Technology Co., Ltd. Copyright © 2018
 */

namespace App\Http\Controllers\Backend\GuestBook;
use App\ConstDir\ErrorConst;
use App\Http\Controllers\Backend\BaseController;
use App\Repository\Models\Guestbook;
use App\Repository\Repositories\Interfaces\GuestbookRepository;
use Illuminate\Http\Request;


class GuestBookController  extends BaseController
{
    protected $guest;
    protected $request;
    public function __construct(GuestbookRepository $guest,Request $request) {
        $this->guest=$guest;
        $this->request=$request;
    }

    /**
     * 考察预约列表
     * 分页
     * */
    public function index(){

        $data=$this->guest->paginate($this->perPage);
        return $this->success(ErrorConst::SUCCESS_CODE, $data, true);
    }

    /**
     * 考察预约详情
     * @param $id
     * @return \Illuminate\Support\Collection
     */
    public function show($id){
        $data=$this->guest->find($id);
        return $this->success(ErrorConst::SUCCESS_CODE, $data);

    }
    /**
     * 考察预约添加
     *
     * */
    public function store(){
        $data=$this->request->all();

        $ret=$this->guest->create($data);
        return $this->success(ErrorConst::SUCCESS_CODE, $data);

    }
    /**
     * 考察预约修改
     *
     * */
    public function update($id){
        $data=$this->request->all();

        $ret=$this->guest->update($data,$id);
        return $this->success(ErrorConst::SUCCESS_CODE, $ret);

    }

    /**
     * 删除考察预约 无软删除
     *
     * */
    public function delete($id){
        $ret=$this->guest->delete($id);
        return $this->success(ErrorConst::SUCCESS_CODE, $ret);
    }
}